import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # 去警告
import tensorflow as tf


def variable_demo():
	"""
	变量的演示
	:return:
	"""
	my_tensor = tf.constant([[1.0, 2.0], [3.0, 4.0]])
	my_variable = tf.Variable(my_tensor)
	bool_varible = tf.Variable([False, False, False, True])
	complex_varible = tf.Variable([5 + 4j, 6 + 1j])
	print("my_variable：\n", my_variable)
	print("bool_varible：\n", bool_varible)
	print("complex_varible：\n", complex_varible)

	print("Shape:", my_variable.shape)
	print("DType:", my_variable.dtype)
	print("As numpty:", my_variable.numpy)

	# 生命周期、命名
	a = tf.Variable(my_tensor, name="Mark")
	b = tf.Variable(my_tensor + 1, name="Mark")

	print(a == b)

	return None


if __name__ == '__main__':
	# 代码7：变量的演示
	variable_demo()
